package jacob;

import org.bouncycastle.crypto.engines.SkipjackEngine;

import net.minecraft.block.Block;
import net.minecraft.block.BlockFluid;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;

public class Lava_Sword extends ItemSword {

	public Lava_Sword(int par1, EnumToolMaterial par2EnumToolMaterial) {
		super(par1, par2EnumToolMaterial);
		// TODO Auto-generated constructor stub
	}
	public void registerIcons(IconRegister iconReg)
    {
        itemIcon = iconReg.registerIcon("iDTechModBase:sword16");
        
    }
	
	/**
	 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
	 */
	public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
	{
	    /*
	    if (!par3EntityPlayer.capabilities.isCreativeMode)
	    {
	        --par1ItemStack.stackSize;
	    }
	    */
	    par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
	
	    if (!par2World.isRemote)
	    {
	            //par3EntityPlayer.entityDropItem(par1ItemStack, par2)
	    	     Vec3 skeyPos = util.placeInFrontOfEntity(par3EntityPlayer, 10);
	    	    // skeyPos.yCoord = par2World.getPrecipitationHeight((int)skeyPos.xCoord,(int) skeyPos.zCoord);
	           // EntityLightningBolt skeley = (EntityLightningBolt)new EntityLightningBolt(par2World, skeyPos.xCoord, skeyPos.yCoord, skeyPos.zCoord);
	    	     tryPlaceLava(par2World, (int)skeyPos.xCoord, (int)skeyPos.yCoord, (int)skeyPos.zCoord);
	            /*
	            skeley.setPosition(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ);
	            skeley.rotationYaw = par3EntityPlayer.rotationYaw - 90;
	            skeley.posX -= ((double)(MathHelper.cos(skeley.rotationYaw / 180.0F * (float)Math.PI) * 0.16F)) * 100;
	        skeley.posZ -= ((double)(MathHelper.sin(skeley.rotationYaw / 180.0F * (float)Math.PI) * 0.16F)) * 100;
	        */
	            
	           
	           //par2World.spaw(skeley);
	    }
	    super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
	    
	
	    return par1ItemStack;
	}
	 /**
     * Attempts to place the liquid contained inside the bucket.
     */
    public boolean tryPlaceLava(World par1World,int par8, int par9, int par10)
    {
       
        
        if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlockMaterial(par8, par9, par10).isSolid())
        {
            return false;
        }
        else
        {
            
            
            par1World.setBlock(par8, par9, par10,  BlockFluid.lavaMoving.blockID, 0, 3);
            return true;
        }
    }
}
